#include <stdio.h>

int    main()
{
    int n;
    while ( scanf( "%d",&n ) != EOF )
    {
        if ( n % 2 == 0 || n <= 1 )
        {
            printf( "2^? mod %d = 1\n", n );
        }
        else 
        {
            int t = 1, s = 0;
            do
            {
                t *= 2;
                s++;
                t %= n;
            }while ( t != 1 );
            printf( "2^%d mod %d = 1\n", s , n );
        }
    }
    return 0;
}
